﻿
@{
    Layout = null;
    var bentity = ViewData["bentity"] as SelectList;
    var lentity = ViewData["lentity"] as SelectList;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Insert</title>
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/multiselect/bootstrap-multiselect.css" rel="stylesheet" />
    <style>
        .ibox {
            margin-bottom: 0px;
        }
            

        .multiselect-container input[type="checkbox"] {
            margin-top: 7px;
        }
        .pull-left {
            padding-left:0px;
        }

        /*.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12,
        .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12,
        .btn-group,div {
            border-style: solid;
            border-width: 1px;
            border-color: #000;
        }*/
        #TitleLabel,#SubjectLabel {
            width:100px;
        }
        .col-sm-12 {
            padding-left:0px;
            padding-right:0px;
        }
        #BtnDiv {
            padding-right:15px;
        }
        .help-block {
            margin-top: 0px;
            margin-bottom: 0px;
        }
    </style>  
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <form class="form-horizontal m-t" id="mainForm">

            <div class="row">
                <div class="col-sm-6">

                    @*<div class="form-group">
                        <label class="col-xs-3 control-label">楼盘省份：</label>
                        <div class="col-xs-9">
                            <select class="form-control" name="ProvinceID" id="ProvinceID">
                                <option value="">请选择省份</option>
                            </select>
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请选择省份</span>
                        </div>
                    </div>*@

                    <div class="form-group">
                        <label class="col-xs-3 control-label">楼盘：</label>
                        <div class="col-xs-9">
                            <select id="BuildingsID" class="form-control input-sm" name="BuildingsID" multiple="multiple"> 
                            </select>
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请填写楼盘</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-3 control-label">装修：</label>
                        <div class="col-xs-9">
                            <select id="DecorationID" class="form-control input-sm" name="DecorationID" multiple="multiple"> 
                            </select>
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请填写装修</span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6"> 
                    <div class="form-group">
                        <label class="col-xs-3 control-label">低价房：</label>
                        <div class="col-xs-9">
                            <select id="LowPriceHousesID" class="form-control input-sm" name="LowPriceHousesID" multiple="multiple"> 
                            </select>
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请填写价格优势</span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label" id="TitleLabel">标题：</label>
                    <div class="col-xs-10" style="width:673px; padding-right:0px;">
                        <input id="Title" name="Title" type="text" class="form-control">
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请填写标题</span>
                    </div>
                </div>
            </div>
            <div class="col-sm-12"> 
                <div class="form-group">
                    <label class="col-xs-2 control-label" id="SubjectLabel">主题：</label>
                    <div class="col-xs-10" style="width:673px; padding-right:0px;"> 
                        <textarea class="form-control" id="Subject" name="Subject" rows="3"></textarea>
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请填写主题</span>
                    </div>
                </div>
            </div> 

            <div class="row">
                <div class="col-sm-12" id="BtnDiv">
                    <button id="submit" class="btn btn-primary pull-right" type="submit">
                        <i class="fa fa-check"></i>&nbsp;提&nbsp;交
                    </button>
                </div>
            </div>
        </form> 
    </div>



    <!-- 全局js -->
    <script type="text/javascript" src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script type="text/javascript" src="~/Scripts/content.js?v=1.0.0"></script>
    <!-- jQuery Validation plugin javascript-->
    <script type="text/javascript" src="~/Scripts/plugins/validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/validate/messages_zh.min.js"></script>
    <script type="text/javascript" src="~/Scripts/Extensions/ExtValidator.js"></script>
    <!-- Bootstrap table -->
    <script type="text/javascript" src="~/Scripts/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <!-- layer javascript -->
    <script type="text/javascript" src="~/Scripts/plugins/layer/layer.min.js"></script>
    <script src="~/Scripts/plugins/layer/laydate/laydate.js"></script>

    @*<script src="~/Areas/Account/Scripts/BrokerageList.js?@DateTime.Now.ToString("yyyyMMddHHmmssfff")"></script>*@
    <script src="~/Scripts/TimeObjectUtil.js"></script>
    <script src="~/Scripts/plugins/multiselect/bootstrap-multiselect.js"></script>

     
     
    <script>
        $(function () {
            GetBuidings();
            GetLowPriceHouses();
            GetDecoration();
            //楼盘多选框
            $('#BuildingsID').multiselect({
                buttonClass: 'btn btn-link',//显示按钮style
                buttonWidth: '265px',//按钮宽度
                inheritClass: true,//继承原来select的button的class
                selectAllNumber: false,//true显示allselect（6）,false显示allselect
            });
            //低价房多选框
            $('#LowPriceHousesID').multiselect({
                buttonClass: 'btn btn-link',//显示按钮style
                buttonWidth: '265px',//按钮宽度
                inheritClass: true,//继承原来select的button的class
                selectAllNumber: false,//true显示allselect（6）,false显示allselect 
            });
            //装修多选框 
            $('#DecorationID').multiselect({
                buttonClass: 'btn btn-link',//显示按钮style
                buttonWidth: '265px',//按钮宽度
                inheritClass: true,//继承原来select的button的class
                selectAllNumber: false,//true显示allselect（6）,false显示allselect
            });
            var icon = "<i class='fa fa-times-circle'></i> ";
            var validator = $("#mainForm").validate({
                rules: { 
                    Title: { required: true, },
                    Subject: { required: true, },
                },
                messages: { 
                    Title: { required: icon + "请输入标题", },
                    Subject: { required: icon + "请输入主题", },
                },
                submitHandler: function (form) {
                    $.ajax({
                        url: '/Dynamic/DynamicInsertAsyunc',
                        type: "post",
                        dataType: "json",
                        data: $('#mainForm').serialize(),
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.type;
                            if (type == 1) {
                                layer.msg(data.content, { icon: 6, time: 2000 },
                                    function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                    });

                            } else {
                                layer.msg(data.content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }
            });
        });
        //楼盘多选框
        function GetBuidings() {
            $.getJSON(
                "/Dynamic/GetBuildingsInsert",
                { 
                },
                function (data) {
                    $("#BuildingsID").find("option").remove();
                    $("#BuildingsID").multiselect("destroy").multiselect({
                        buttonClass: 'btn btn-link',//显示按钮style
                        buttonWidth: '265px',//按钮宽度
                        inheritClass: true,//继承原来select的button的class
                        selectAllNumber: false,//true显示allselect（6）,false显示allselec
                    }); 
                    $.each(data, function (i, item) {
                         
                        $("<option></option>").val(item["id"]).text(item["name"]).appendTo($("#BuildingsID"));


                        $("#BuildingsID").multiselect("destroy").multiselect({
                            buttonClass: 'btn btn-link',//显示按钮style
                            buttonWidth: '265px',//按钮宽度
                            inheritClass: true,//继承原来select的button的class
                            selectAllNumber: false,//true显示allselect（6）,false显示allselec
                        });
                    });
                });
        }
        //低价房多选框
        function GetLowPriceHouses() {
            $.getJSON(
                "/Dynamic/GetLowPriceHousesInsert",
                {
                },
                function (data) {
                    $("#LowPriceHousesID").find("option").remove();
                    $("#LowPriceHousesID").multiselect("destroy").multiselect({
                        buttonClass: 'btn btn-link',//显示按钮style
                        buttonWidth: '265px',//按钮宽度
                        inheritClass: true,//继承原来select的button的class
                        selectAllNumber: false,//true显示allselect（6）,false显示allselec
                    });
                    $.each(data, function (i, item) {

                        $("<option></option>").val(item["id"]).text(item["name"]).appendTo($("#LowPriceHousesID"));


                        $("#LowPriceHousesID").multiselect("destroy").multiselect({
                            buttonClass: 'btn btn-link',//显示按钮style
                            buttonWidth: '265px',//按钮宽度
                            inheritClass: true,//继承原来select的button的class
                            selectAllNumber: false,//true显示allselect（6）,false显示allselec
                        });
                    });
                });
        }
        //装修多选框 
        function GetDecoration() {
            $.getJSON(
                "/Dynamic/GetDecorationInsert",
                {
                },
                function (data) {
                    $("#DecorationID").find("option").remove();
                    $("#DecorationID").multiselect("destroy").multiselect({
                        buttonClass: 'btn btn-link',//显示按钮style
                        buttonWidth: '265px',//按钮宽度
                        inheritClass: true,//继承原来select的button的class
                        selectAllNumber: false,//true显示allselect（6）,false显示allselec
                    });
                    $.each(data, function (i, item) {

                        $("<option></option>").val(item["id"]).text(item["name"]).appendTo($("#DecorationID"));


                        $("#DecorationID").multiselect("destroy").multiselect({
                            buttonClass: 'btn btn-link',//显示按钮style
                            buttonWidth: '265px',//按钮宽度
                            inheritClass: true,//继承原来select的button的class
                            selectAllNumber: false,//true显示allselect（6）,false显示allselec
                        });
                    });
                });
        }
    </script>
</body>
</html>